const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const evaluationSchema = new Schema({
    userId: {
        type: Schema.Types.ObjectId,
        ref: "muser",
        required: true
    },
    evaluations: [
        {
            goodId: { type: Schema.Types.ObjectId, ref: 'good' }, // 商品ID，关联到商品表的ID字段

            basetags: [
                {
                    type: Schema.Types.ObjectId,
                    ref: "tags",//关联的标签模型名称，根据实际情况修改
                    required: true
                }
            ],
            ratingtags: [
                {
                    type: Schema.Types.ObjectId,
                    ref: "tags",//关联的标签模型名称，根据实际情况修改
                    required: true
                }
            ],
            rating: {
                type: Number,
                required: true,
                min: 1,
                max: 5
            },
            comment: {
                type: String,
                required: false,
                trim: true
            },
            images: {
                type: [String], // 图片链接数组
                default: []
            },
            createdAt: {
                type: Number,
                default: Date.now
            }
        }
    ]

})
const Evaluation = mongoose.model("evaluation", evaluationSchema);
module.exports = Evaluation;
